<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="PostUploads.aspx.cs" Inherits="PostUploads" Title="Untitled Page" %>

<%@ Register Src="UserControls/PostHeader.ascx" TagName="PostHeader" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="phActions" Runat="Server">
    <asp:HyperLink ID="lnkList" runat="server" NavigateUrl="~/PostUploadList.aspx">List All Posts</asp:HyperLink>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phMain" Runat="Server">
    <uc1:PostHeader ID="postHeader" runat="server" />
    <telerik:RadGrid ID="gvUploads" runat="server" DataSourceID="dsUploads" GridLines="None" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowGroupPanel="True" OnItemCommand="gvUploads_ItemCommand" OnItemDataBound="gvUploads_ItemDataBound">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView DataSourceID="dsUploads" DataKeyNames="Id,ConcurencyId" AllowAutomaticDeletes="True">
            <RowIndicatorColumn Visible="False">
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="False">
                <HeaderStyle Width="19px" />
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn">
                    <ItemTemplate><%#Container.ItemIndex + 1 + (gvUploads.PageSize * gvUploads.CurrentPageIndex)%></ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="Created" DataType="System.DateTime" HeaderText="Uploaded"
                    ReadOnly="True" SortExpression="Created" UniqueName="column">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" ReadOnly="True"
                    SortExpression="UserName" UniqueName="column1">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn1">
                    <ItemTemplate>
                        <acms:AcmsImage ID="thumbImage" runat="server" FileId='<%#Eval("FileId") %>' RenderWidth="50" RenderHeight="50" />
                        <ajax:ModalPopupExtender id="pop" TargetControlID="thumbImage" PopupControlID="fullPanel" OkControlID="fullImage" Drag="false" RepositionMode="None" DropShadow="false" runat="server" />
                        <asp:Panel ID="fullPanel" runat="server">
                            <acms:AcmsImage ID="fullImage" runat="server" FileId='<%#Eval("FileId") %>' RenderWidth="800" RenderHeight="600" />
                        </asp:Panel>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="column2">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Comment" HeaderText="Comment" UniqueName="column3">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="Rating" SortExpression="AverageVote" UniqueName="TemplateColumn5">
                    <ItemStyle Width="70px" />
                    <ItemTemplate>
                        <ajax:Rating ID="rating" MaxRating="5" CurrentRating='<%#(int)Math.Round((decimal)Eval("AverageVote") * 5, MidpointRounding.AwayFromZero) %>' EmptyStarCssClass="emptyRatingStar" FilledStarCssClass="filledRatingStar"
                        StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" runat="server" ReadOnly="True" OnClick="javascript:return false">
                        </ajax:Rating>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="Reviewed" HeaderText="Reviewed" UniqueName="column4">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Reported" HeaderText="Reported" UniqueName="column5">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Suspended" HeaderText="Suspended" UniqueName="column6">
                </telerik:GridBoundColumn>
                <telerik:GridHyperLinkColumn Text="Details" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/PostUploadDetails.aspx?Id={0}" />
                <telerik:GridTemplateColumn UniqueName="colApprove" Visible="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkReviwed" OnClientClick='javascript:return confirm("Are you sure you want to mark this upload as reviewed?");' Text="Approve" CommandName="Reviewed" CommandArgument='<%#Eval("Id") %>' Visible='<%# !((bool)Eval("Reviewed") && !(bool)Eval("Suspended")) %>' runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn UniqueName="colSuspend" Visible="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkSuspend" OnClientClick='javascript:return confirm("Are you sure you want to mark this upload as suspended?");' Text="Suspend" CommandName="Suspend" CommandArgument='<%#Eval("Id") %>' Visible='<%# !(bool)Eval("Suspended") %>' runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn UniqueName="colDelete" Visible="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkDelete" OnClientClick='javascript:return confirm("Are you sure you want to delete this upload?");' Text="Delete" CommandName="Delete" CommandArgument='<%#Eval("Id") %>' runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowDragToGroup="True">
        </ClientSettings>
    </telerik:RadGrid>
    <acms:UserPostUploadDataSource ID="dsUploads" runat="server" EnablePaging="False" OnSelectData="dsUploads_SelectData">
    </acms:UserPostUploadDataSource>
</asp:Content>

